<template>
    <van-row>
        <van-col :span="24">
            <van-form @submit="onSubmit">
                <van-cell-group inset>
                    <van-field
                    v-model="username"
                    name="username"
                    label="用户名"
                    placeholder="用户名"
                    :rules="[{ required: true, message: '请填写用户名' }]"
                    />
                    <van-field
                    v-model="password"
                    type="password"
                    name="password"
                    label="密码"
                    placeholder="密码"
                    :rules="[{ required: true, message: '请填写密码' }]"
                    />
                </van-cell-group>
                <div style="margin: 16px;">
                    <van-button round block type="primary" native-type="submit">
                        提交
                    </van-button>
                </div>
                </van-form>
        </van-col>
    </van-row>
</template>

<script setup>
import { ref,getCurrentInstance } from "vue";
import {showNotify} from 'vant';

const {proxy} = getCurrentInstance();

const username = ref('');
const password = ref('');

const onSubmit = (values) => {
    console.log('submit', values);
    // proxy.$axios({
    //     method: 'post',
    //     url: '/login',
    //     data: values
    // }).then(res=>{
    //     let resultBean = res.data;
    //     if(resultBean.code == 200){
    //        let user = resultBean.data;
    //        window.localStorage.setItem('loginUser',JSON.stringify(user));
    //        console.log('history----',window.history);
    //        proxy.$router.push("/main");
    //     }else{
    //         showNotify({message: resultBean.msg});
    //     }
    // }).catch(error=>{
    //     showNotify({message: error.message});
    // })

};


</script>

<style>
</style>